package problem;

import java.util.Arrays;

import javax.swing.RootPaneContainer;

import lxy.TreeNode;

public class problem108 {
	public static void main(String[] args) {
		int[] nums = {1,2,3,4,5};
		TreeNode root = sortedArrayToBST(nums);
		root.DeepSearch(root);
	}

    public static TreeNode sortedArrayToBST(int[] nums) {
    
    	if(nums == null|| nums.length== 0){
    		return null;
    	}
    	int len = nums.length;
    	TreeNode root = new TreeNode(nums[len/2]);
    	int [] leftnums = Arrays.copyOfRange(nums, 0,len/2);
    	int [] rightnums = Arrays.copyOfRange(nums, len/2+1,len);
    	root.left = sortedArrayToBST(leftnums);
    	root.right = sortedArrayToBST(rightnums);
    	return root;
    }
}
